package com.shiwenping.reply;

import android.app.Application;

import com.alibaba.android.arouter.launcher.ARouter;
import com.andview.refreshview.utils.LogUtils;
import com.shiwenping.reply.tools.Path;

import java.util.ArrayList;
import java.util.List;

import io.realm.Realm;

/**
 * @author shiwenping
 * @date 17-11-6 下午2:17
 */

public class App extends Application {
    private static List<BaseActivity> activities = new ArrayList<>();

    public static void add(BaseActivity baseActivity) {
        activities.add(baseActivity);
    }

    public static void remove(BaseActivity baseActivity) {
        activities.remove(baseActivity);
    }

    public static void exitToLoginActivity() {
        ARouter.getInstance().build(Path.MAIN_LOGIN).navigation();
        for (BaseActivity activity : activities) {
            if (!(activity instanceof LoginActivity)) {
                activity.finish();
            }
        }
    }


    @Override
    public void onCreate() {
        super.onCreate();
        ARouter.openLog();
        ARouter.openDebug();
        ARouter.init(this);
        LogUtils.enableLog(false);
        Realm.init(this);
    }
}
